<template>
	<div class="child">
		<h2>我是Child组件</h2>
		<h3>我有一个玩具：{{toy}}</h3>
		<h3>我正在听歌曲：{{music}}</h3>
		<button @click="handleToy">把我的玩具给父亲</button>
		<button @click="handleMusic">把我的歌曲给父亲</button>
		<button @click="handleOff">点我解绑身上的send-music事件</button>
	</div>
</template>

<script>
	export default {
		name:'Child',
		data() {
			return {
				toy:'奥特曼',
				music:'《向天再借五百年》'
			}
		},
		methods: {
			handleToy(){
				this.$emit('send-toy',this.toy)
			},
			handleMusic(){
				this.$emit('send-music',this.music)
			},
			handleOff(){
				this.$off('send-music')
			}
		},
	}
</script>

<style scoped>
	.child{
		background-color: orange;
		padding: 20px;
	}
</style>